package io.wongxd.solution.universalCache

import io.wongxd.solution.universalCache.keep.Cache
import io.wongxd.solution.universalCache.keep.MemoryCache

@Suppress("Unused")
fun <T: Any> CachedSourceNoParams(
    source: suspend () -> T,
    cache: Cache<Int, T> = MemoryCache(1),
) = CachedSource(
    { source() }, cache
)

suspend fun <T: Any> CachedSource<Int, T>.getByNorParams(
    fromCache: FromCache,
    shareOngoingRequest: Boolean = true,
    maxAge: Long? = null,
    additionalKey: Any? = null,
) = get(
    0,
    fromCache,
    shareOngoingRequest,
    maxAge,
    additionalKey,
)